home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- #include <dos/dos.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
-
- #include <clib/AMarquee_protos.h>
-
- #include <pragmas/AMarquee_pragmas.h>
-
- struct Library * AMarqueeBase = NULL;
- struct QSession * session = NULL;
-
- void CleanExit(void)
- {
- if (session) QFreeSession(session); /* This MUST be done before we close the library! */
- if (AMarqueeBase) CloseLibrary(AMarqueeBase);
- printf("All done.\n");
- }
-
- /* Main program--simply increments our counter whenever someone else increments theirs */
- int main(int argc, char ** argv)
- {
- char * connectTo, * progName;
- int port = 2957;
- BOOL BPut = FALSE;
- BOOL BDie = FALSE;
-
- atexit(CleanExit);
-
- printf("Usage: RemoveTest [hostname=localhost] [name=removetest]\n");
-
- connectTo = (argc>1) ? argv[1] : "localhost";
- progName = (argc>2) ? argv[2] : "removetest";
-
- if ((AMarqueeBase = OpenLibrary("amarquee.library",37L)) == NULL)
- {
- printf("Couldn't open amarquee.library v37!\n");
- exit(RETURN_ERROR);
- }
-
- printf("connecting to %s:%i...\n",connectTo, port);
- if ((session = QNewSession(connectTo, port, progName)) == NULL)
- {
- printf("Couldn't connect to server %s:%i\n",connectTo, port);
- CloseLibrary(AMarqueeBase);
- exit(RETURN_WARN);
- }
-
- printf("RemoveTest connected to server %s:%i\n",connectTo, port);
-
- /* Setup */
- (void)QSetOp(session, "switch", "", 1L);
- (void)QGo(session,QGOF_SYNC);
-
- while(BDie == FALSE)
- {
- struct QMessage * qMsg;
- ULONG signals = (1L << session->qMsgPort->mp_SigBit) | (SIGBREAKF_CTRL_C);
-
- /* Wait for next message from the server */
- signals = Wait(signals);
-
- if (signals & (1L << session->qMsgPort->mp_SigBit))
- {
- while(qMsg = (struct QMessage *) GetMsg(session->qMsgPort))
- {
- if (qMsg->qm_Status != QERROR_NO_ERROR)
- {
- printf("Error %i detected!\n", qMsg->qm_Status);
- BDie = TRUE;
- }
- else
- {
- /* It must be the sync signal, meaning everyone else has seen our update */
- printf("Synced, now %s switch...\n", BPut ? "setting" : "removing");
-
- if (BPut) (void) QSetOp(session, "switch", "", 1L);
- else (void) QDeleteOp(session, "switch");
- (void) QGo(session,QGOF_SYNC);
-
- if (BPut) BPut = FALSE; else BPut = TRUE;
- }
- FreeQMessage(session,qMsg);
- }
- }
- if (signals & SIGBREAKF_CTRL_C) BDie = TRUE; /* Quit if CTRL-C pressed */
- }
- }
-